package org.sport.model.entityModel;

import javax.persistence.*;

/**
 * Created by Allen on 2017/10/11.
 */
@Entity
@Table(name = "locationtable", schema = "sportinfo", catalog = "")
public class LocationtableEntity {
    private Double longitude;
    private Double latitude;
    private int id;
    private SporthistorytableEntity sporthistorytableBySpohisId;

    @Basic
    @Column(name = "longitude", nullable = true, precision = 0)
    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    @Basic
    @Column(name = "latitude", nullable = true, precision = 0)
    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    @Id
    @Column(name = "_id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LocationtableEntity that = (LocationtableEntity) o;

        if (id != that.id) return false;
        if (longitude != null ? !longitude.equals(that.longitude) : that.longitude != null) return false;
        if (latitude != null ? !latitude.equals(that.latitude) : that.latitude != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = longitude != null ? longitude.hashCode() : 0;
        result = 31 * result + (latitude != null ? latitude.hashCode() : 0);
        result = 31 * result + id;
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "spohis_id", referencedColumnName = "_id")
    public SporthistorytableEntity getSporthistorytableBySpohisId() {
        return sporthistorytableBySpohisId;
    }

    public void setSporthistorytableBySpohisId(SporthistorytableEntity sporthistorytableBySpohisId) {
        this.sporthistorytableBySpohisId = sporthistorytableBySpohisId;
    }
}
